package com.newtouch.avmarketing.mgr.modules.avmarkrting.api;

import com.alibaba.fastjson.JSONObject;
import com.newtouch.avmarketing.mgr.modules.avmarkrting.service.OcrCardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

@Slf4j
@RestController
@RequestMapping("/ocr")
@Api(tags = "04 OCR识别")
public class OcrCardApi {

    @Resource
    private OcrCardService ocrCardService;

    @PostMapping(value = "/ocrCard")
    @ApiOperation(value = "ocr认证")
    public JSONObject ocrCard(@RequestParam("filePath") String filePath) throws IOException {
        String result = ocrCardService.ocrCard(filePath);
        JSONObject jsonObject = JSONObject.parseObject(result);
//        return Result.of(ResultCodes.SUCCESS_CODE,"识别成功",jsonObject);
        return jsonObject;
    }
}
